# -*- coding: utf-8 -*-
# !/usr/bin/env python
# @ author = 'zoushunli'
# @ author_email = '409358374@qq.com'

from contextlib import contextmanager

log_file = ''

def you_task():
    pass

@contextmanager
def close_stdout():

    raw_stdout = sys.stdout
    file = open(log_file, 'a+')
    sys.stdout = file
    yield
    sys.stdout = raw_stdout
    file.close()

with close_stdout():
    you_task()
